<layout name="layout" />
<link rel="stylesheet" href="/Css/algorithm.css" type="text/css">
<div class="pageheader notab">
    <h1 class="pagetitle">
        <a href="/" class="linkWay">首页/思路优化</a>
        &nbsp;<span class="divider">»</span>&nbsp;
        <a class="currentWay">新增思路</a>
    </h1>
</div>
<div id="contentwrapper" class="contentwrapper">
</div>
<include file="{APP_PATH}Template/Algorithm/editor.html" />
<script type="text/javascript">
    var user_id = {$me['user_id']};
    var device = '{$device}';
    var adgroup_ids = '{$adgroup_ids}';
    var campaign_ids = '{$campaign_ids}';
    $(document).ready(function(){
        var data = {user_id: user_id, device: device};
        if(adgroup_ids){
            data.adgroup_ids = [];
            $.each(adgroup_ids.split(','), function(){
               if($.isNumeric(this)){
                   data.adgroup_ids.push(parseInt(this));
               }
            });
        }
        if(campaign_ids){
            data.campaign_ids = [];
            $.each(campaign_ids.split(','), function(){
                if($.isNumeric(this)){
                    data.campaign_ids.push(parseInt(this));
                }
            });
        }
        editor = algorithm.editor($('.contentwrapper'), data);
        editor.on('saved', function(semiatuo){
           location.href = '/algorithm/semiauto_list';
        });
        editor.init();
        editor.add();
    });
</script>